package com.dmx.fw.web.struts2.components;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.TextField;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;

import com.opensymphony.xwork2.util.ValueStack;

@StrutsTag(
	    name="date",
	    tldTagClass="com.dmx.fw.web.struts2.views.tags.ExtDateTag",
	    description="Render an HTML input field of type text",
	    allowDynamicAttributes=true)
public class ExtDate extends TextField {
	
	protected String pageState;
	protected String addState;
	protected String editState;
	protected String viewState;
	protected String outHidden;

	public ExtDate(ValueStack stack, HttpServletRequest request,
			HttpServletResponse response) {
		super(stack, request, response);
		// TODO Auto-generated constructor stub
	}
	
	protected String getDefaultTemplate() {
        return "extdate";
    }
	
	protected void evaluateExtraParams(){
		super.evaluateExtraParams();
		
		 if (pageState != null) {
	        addParameter("pageState", findString(pageState));
	     }
		 if (addState != null) {
		        addParameter("addState", findString(addState));
		     }
		 if (editState != null) {
		        addParameter("editState", findString(editState));
		     }
		 if (viewState != null) {
		        addParameter("viewState", findString(viewState));
		     }
		 if (outHidden != null) {
		        addParameter("outHidden", findString(outHidden));
		     }
	}
	
	@StrutsTagAttribute(description="pageState attribute", type="String")
	public void setPageState(String pageState) {
		this.pageState = pageState;
	}

	@StrutsTagAttribute(description="addState attribute", type="String")
	public void setAddState(String addState) {
		this.addState = addState;
	}

	@StrutsTagAttribute(description="editState attribute", type="String")
	public void setEditState(String editState) {
		this.editState = editState;
	}

	@StrutsTagAttribute(description="viewState attribute", type="String")
	public void setViewState(String viewState) {
		this.viewState = viewState;
	}

	@StrutsTagAttribute(description="outHidden attribute", type="Boolean")
	public void setOutHidden(String outHidden) {
		this.outHidden = outHidden;
	}

}
